package com.compiler.model;

import java.util.ArrayList;

import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;


/**
 * Created by huilin on 2017/12/10.
 */

public class MvpServiceType {

    public TypeElement typeElement;
    public ArrayList<ExecutableElement> mMethods;


    public MvpServiceType(Element element) {
        if (element.getKind() != ElementKind.INTERFACE) {
            throw new RuntimeException("is not interface");
        }
        mMethods = new ArrayList<>();
        typeElement = (TypeElement) element;
        for (Element element1 : typeElement.getEnclosedElements()) {
            if (element1.getKind() == ElementKind.METHOD) {
                mMethods.add((ExecutableElement) element1);
            }
        }
    }

    public TypeMirror getModelName() {
        return typeElement.asType();
    }

    public String getSimpleName(){
        return typeElement.getSimpleName().toString();
    }

    public String mvpClassName(){
        return typeElement.getEnclosingElement().getSimpleName().toString();
    }
}
